﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GUI
{
    public class StaticVariables
    {
        public static byte TuoiToiDa;
        public static byte TuoiToiTieu;
        public static int ThoiHanThe;
        public static int KhoangCachNamXB;
        public static int SoLuongMuonToiDa;
        public static int ThoiGianMuonToiDa;
        public static decimal TienPhat;
        public static string UserID;
        public static string UserPw;
        public static string UserRole;
        public static int UserAuthorizationID;
        public static string UserAuthorizationString;
        public static int UserPriority;
        public static bool QuanlyEnable;
        public static bool CuonsachEnable;
        public static bool LoaisachEnable;
        public static bool TuadeEnable;
        public static bool LanxbEnable;
        public static bool BaotcEnable;
        public static bool KyxbEnable;
        public static bool NhaxbEnable;
        public static bool DocgiaEnable;
        public static bool MuonsachEnable;
        public static bool TrasachEnable;
        public static bool ThutienEnable;
        public static bool TacgiaEnable;
        public static bool TuadetacgiaEnable;
        public static bool TratreEnable;
        public static bool LuotmuonEnable;
        public static bool TimkiemEnable;
        public static bool SuaquidinhEnable;
        public static bool LoginEnable;
        public static bool LogoutEnable;
        public static bool UserControlEnable;
        public static bool UserManagement;
        public static bool HelpEnable;
        public static void SetDefault()
        {
            UserID = "";
            UserPw = "";
            UserRole = "";
            UserAuthorizationID = 0;
            UserAuthorizationString = "";
            UserPriority = 0;
            QuanlyEnable = false;
            CuonsachEnable = false;
            LoaisachEnable = false;
            TuadeEnable = false;
            LanxbEnable = false;
            BaotcEnable = false;
            KyxbEnable = false;
            NhaxbEnable = false;
            DocgiaEnable = false;
            TrasachEnable = false;
            ThutienEnable = false;
            TacgiaEnable = false;
            TuadetacgiaEnable = false;
            TratreEnable = false;
            LuotmuonEnable = false;
            TimkiemEnable = false;
            SuaquidinhEnable = false;
            LoginEnable = true;
            LogoutEnable = false;
            UserControlEnable = false;
            UserManagement = false;
            HelpEnable = false;
        }
        public static void SetViaAuthorization()
        {
            if (UserAuthorizationString == "")
                return;
            Char[] author = UserAuthorizationString.ToCharArray();
            try
            {
                if (author[0] == '0')
                {
                    QuanlyEnable = false;
                    CuonsachEnable = false;
                    LoaisachEnable = false;
                    TuadeEnable = false;
                    LanxbEnable = false;
                    BaotcEnable = false;
                    KyxbEnable = false;
                    NhaxbEnable = false;
                    DocgiaEnable = false;
                    TrasachEnable = false;
                    ThutienEnable = false;
                    TacgiaEnable = false;
                    TuadetacgiaEnable = false;
                }
                else
                {
                    QuanlyEnable = true;
                    CuonsachEnable = true;
                    LoaisachEnable = true;
                    TuadeEnable = true;
                    LanxbEnable = true;
                    BaotcEnable = true;
                    KyxbEnable = true;
                    NhaxbEnable = true;
                    DocgiaEnable = true;
                    TrasachEnable = true;
                    ThutienEnable = true;
                    TacgiaEnable = true;
                    TuadetacgiaEnable = true;
                }
                if (author[1] == '0')
                {
                    TratreEnable = false;
                    LuotmuonEnable = false;
                }
                else
                {
                    TratreEnable = true;
                    LuotmuonEnable = true;
                }
                if (author[2] == '0')
                {
                    TimkiemEnable = false;
                }
                else
                {
                    TimkiemEnable = true;
                }
                if (author[3] == '0')
                {
                    SuaquidinhEnable = false;
                }
                else
                {
                    SuaquidinhEnable = true;
                }
                if (author[4] == '0')
                {
                    LoginEnable = false;
                }
                else
                {
                    LoginEnable = true;
                }

                if (author[5] == '0')
                {
                    LogoutEnable = false;
                }
                else
                {
                    LogoutEnable = true;
                }

                if (author[6] == '0')
                {
                    UserControlEnable = false;
                }
                else
                {
                    UserControlEnable = true;
                }

                if (author[7] == '0')
                {
                    UserManagement = false;
                }
                else
                {
                    UserManagement = true;
                }

                if (author[8] == '0')
                {
                    HelpEnable = false;
                }
                else
                {
                    HelpEnable = true;
                }
            }
            catch (Exception ex)
            {
            }
        }
    }
}
